<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>JSP Page</title>
		<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
		<!-- 引用Vue -->

		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
		<!-- 引入组件库 -->
		<script src="https://unpkg.com/element-ui/lib/index.js"></script>

		<script type="text/javascript" src="js/axios.js"></script>
		<script type="text/javascript" src="js/qs.js"></script>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
			
			.app {
				width: 750px;
				height: auto;
				font-size: 12px;
			}
			
			.title {
				width: 96%;
				height: 50px;
				margin: 10px auto;
				border-bottom: 1px solid darkgray;
			}
			
			.title h4 {
				font-size: 18px;
				font-weight: 500;
				color: #000 !important;
				margin-top: 10px;
			}
		</style>
	</head>
	

	<body>
		<div id="app" class="app">
			<div class="title">
				<h4 style="float: left;">付款计划（应付）</h4>
				<span style="float: right;"><el-button @click="onSubmit('form')"><i class="el-icon-check"></i>保存</el-button></span>
			</div>
			<el-form ref="form" :model="form" :rules="rules" label-width="100px">
					<el-form-item label="供应商" prop="sname">
						<el-input v-model="form.sname" placeholder="${da.supname}" disabled></el-input>
					</el-form-item>
					
					<el-form-item label="采购单"prop="purchase">
						<el-input v-model="form.purchase" placeholder="${da.theme}" disabled></el-input>
					</el-form-item>
					
					<el-form-item label="付款日期">
						<el-col :span="8">
						<el-form-item prop="date1">
							<el-date-picker type="date" v-model="form.date1"
							placeholder="选择日期" :picker-options="pickerOptions0"></el-date-picker>
						</el-form-item>
						</el-col>
						<el-col :span="12" :offset="2">
					<el-form-item label="金额" prop="money">
						<el-input v-model="form.money" disabled placeholder="${da.schsum}"></el-input>
					</el-form-item>
						</el-col>
				</el-form-item>
				
			
					<!-- <el-form-item label="是否付款">
						<el-col :span="8">
						<el-form-item prop="pay">
						<el-radio-group v-model="form.pay">
							<el-radio :label="2999">已开票</el-radio>
							<el-radio :label="3000">未开票</el-radio>
						</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col :span="12" :offset="2">
						<el-form-item label="付款方式" prop="way">
						<el-select v-model="form.way" placeholder="请选择">
							<el-option :key="3005" label="支票" :value="3005" ></el-option>
							<el-option :key="3006" label="现金" :value="3006" ></el-option>
    						<el-option :key="3007" label="邮政汇款" :value="3007"></el-option>
    						<el-option :key="3008" label="电汇" :value="3008"></el-option>
    						<el-option :key="3009" label="网上银行" :value="3009"></el-option>
    						<el-option :key="3010" label="现款现货" :value="3010"></el-option>
    						<el-option :key="3011" label="货到付款" :value="3011"></el-option>
    						<el-option :key="3012" label="先款后货" :value="3012"></el-option>
						</el-select>
					</el-form-item>
					</el-col>
					</el-form-item> -->
					<el-form-item label="负责人" prop="userid">
						<el-input v-model="form.username" placeholder="${username}" disabled></el-input>
					</el-form-item>
					
					<el-form-item label="备注" prop="remark">
				<el-input type="textarea" :rows="2" v-model="form.remark"></el-input>
					</el-form-item>
					

			</el-form>
			<div class="title">
				<span style="float: right;"><el-button @click="onSubmit('form')"><i class="el-icon-check"></i>保存</el-button></span>
			</div>

		</div>

		<script type="text/javascript">
			var vm = new Vue({
				el: ".app",
				data: {
					pickerOptions0: {
				          disabledDate(time) {
				              return time.getTime() < Date.now() - 8.64e7;
				            }
				          },
					form: {
						sname: '',
						schno:'',
						purchase: '',
						date1: '',
						money: '',
						schsum:'',
						pay: '',
						way: '',
						userid: ${useid},
						username:'',
						remark: ''
					},
					rules: {
					}

				},
				methods: {
					onSubmit(formName) {
						//验证方法
						this.$refs[formName].validate((valid) => {
							if(valid) {
								this.form.schno = ${da.schno};
								this.form.money = ${da.schsum};
								//post提交数据
								axios.post("/addpayplan",
									//参数转换
									Qs.stringify(this.form, {
										arrayFormat: 'brackets'
									})
									
								).then(function(v) {
									window.parent.location.href="/purchasedesc";
								}).catch(function(e) {
									alert("出错了"+e);
								});

							} else {
								console.log('error submit!!');
								return false;
							}
						});
					}
				},
				mounted() {
					this.form.username = ${username};
					this.form.userid = ${useid};
					
					/* var p = ${da};
						this.form.schno = li.schno;
						this.form.money = li.schsum; */
					
				}

			});
		</script>

	</body>

</html>